package com.itita.ww2.model.worldmap;

import java.util.Collection;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 区块
 * @author NorthLan
 *
 */
public class Block {
	private int id; // blockId
	private ConcurrentHashMap<Integer, City> cityMap; // 城市地图

	public Block(int id) {
		this.id = id;
		this.cityMap = new ConcurrentHashMap<>();
	}

	public void addCity(int cityId) {
		if (cityMap.containsKey(cityId)) {
			return;
		}
		cityMap.put(cityId, new City(cityId, this));
	}

	public City getCity(int cityId) {
		return cityMap.get(cityId);
	}

	public boolean isCityExists(int cityId) {
		return cityMap.containsKey(cityId);
	}

	public int getId() {
		return id;
	}

	public Collection<City> getAllCity() {
		return cityMap.values();
	}

}
